#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>

#define err() do { perror("client8"); exit(EXIT_FAILURE); } while(0)

int main(int argc, char *argv[])
{
	struct sockaddr_un address;
 	int socket_fd, r;
	char data[1024];
	if((socket_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0 ) err();
	address.sun_family = AF_UNIX;
	strcpy(address.sun_path, "./socket");
 	if(connect(socket_fd, (struct sockaddr *) &address, sizeof(struct sockaddr_un)) != 0) err();
	if((r = read(socket_fd, data, 1024)) < 0) err();
	printf(data);
	close(socket_fd);
	return 0;
}
